#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define N 5
int The_min_of_max(int brr[N][N])
{
	int x[N], min;
	for (int i = 0; i < N; i++)
	{
		x[i] = brr[i][0];
		for (int j = 0; j < N; j++)
		{
			if (x[i] < brr[i][j])
				x[i] = brr[i][j];
		}
	}
	min = x[0];
	for (int i = 0; i < N; i++)
	{
		if (min > x[i])
			min = x[i];
	}
	return min;
}
int main()
{
	int arr[N][N];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
			scanf("%d", &arr[i][j]);
	}
	int n = The_min_of_max(arr);
	printf("%d", n);
	return 0;
}